package com.ruoyi.exam.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.exam.domain.PWrongQuestion;
import com.ruoyi.exam.mapper.PWrongQuestionMapper;
import com.ruoyi.exam.service.IPWrongQuestionService;
import com.ruoyi.exam.vo.WrongQuestionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 错题记录Service业务层处理
 *
 * @author jiadun
 * @date 2022-01-10
 */
@Service
public class PWrongQuestionServiceImpl implements IPWrongQuestionService
{
    @Autowired
    private PWrongQuestionMapper pWrongQuestionMapper;

    /**
     * 查询错题记录
     *
     * @param id 错题记录主键
     * @return 错题记录
     */
    @Override
    public PWrongQuestion selectPWrongQuestionById(Long id)
    {
        return pWrongQuestionMapper.selectPWrongQuestionById(id);
    }

    /**
     * 查询错题记录列表
     *
     * @param pWrongQuestion 错题记录
     * @return 错题记录
     */
    @Override
    public List<PWrongQuestion> selectPWrongQuestionList(PWrongQuestion pWrongQuestion)
    {
        return pWrongQuestionMapper.selectPWrongQuestionList(pWrongQuestion);
    }

    /**
     * 新增错题记录
     *
     * @param pWrongQuestion 错题记录
     * @return 结果
     */
    @Override
    public int insertPWrongQuestion(PWrongQuestion pWrongQuestion)
    {
        pWrongQuestion.setCreateTime(DateUtils.getNowDate());
        return pWrongQuestionMapper.insertPWrongQuestion(pWrongQuestion);
    }

    /**
     * 修改错题记录
     *
     * @param pWrongQuestion 错题记录
     * @return 结果
     */
    @Override
    public int updatePWrongQuestion(PWrongQuestion pWrongQuestion)
    {
        pWrongQuestion.setUpdateTime(DateUtils.getNowDate());
        return pWrongQuestionMapper.updatePWrongQuestion(pWrongQuestion);
    }

    /**
     * 批量删除错题记录
     *
     * @param ids 需要删除的错题记录主键
     * @return 结果
     */
    @Override
    public int deletePWrongQuestionByIds(Long[] ids)
    {
        return pWrongQuestionMapper.deletePWrongQuestionByIds(ids);
    }

    /**
     * 删除错题记录信息
     *
     * @param id 错题记录主键
     * @return 结果
     */
    @Override
    public int deletePWrongQuestionById(Long id)
    {
        return pWrongQuestionMapper.deletePWrongQuestionById(id);
    }

    @Override
    public List<WrongQuestionResult> selectwrongQuestion(PWrongQuestion pWrongQuestion) {
        return pWrongQuestionMapper.selectwrongQuestion(pWrongQuestion);
    }

  @Override
  public List<WrongQuestionResult> selectwrongQuestionByType(PWrongQuestion pWrongQuestion) {
    return pWrongQuestionMapper.selectwrongQuestionByType(pWrongQuestion);

  }
}
